package com.bgds.sys.api.factory;


import java.util.concurrent.ConcurrentHashMap;

/**
 * @author chenchao
 * @desc 基于享元模式优化
 * @date 2022/1/19 19:03
 */
public class MsgKeyFactory {

    private static final ConcurrentHashMap<String, Long> msgKeyMap = new ConcurrentHashMap<>();

    public static Boolean getIsSync(String key, Long time) {
        Long val = msgKeyMap.containsKey(key) ? msgKeyMap.get(key) : 0L;
        if (time < val) {
            return false;
        }
        msgKeyMap.put(key, time + (1000 * 60 * 3));
        return true;
    }


}
